package day_2022_7_to_8.day48;

/**
 * @author haomin
 * @date 2022/08/21 10:41
 **/
public class Day36_3_Num6152_MinNumberOfHours {
    class Solution {
        public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {
            int n = 0;
            for(int i = 0; i < energy.length; ++i){
                int m = 0, k = 0;
                if(initialEnergy > energy[i] && initialExperience > experience[i]){
                    initialEnergy -= energy[i];
                    initialExperience += experience[i];
                }else if(initialEnergy > energy[i] && initialExperience <= experience[i]) {

                    while (initialExperience <= experience[i]) {
                        m++;
                        initialExperience ++;
                    }
                    initialEnergy -= energy[i];
                    initialExperience += experience[i];
                }else if(initialEnergy <= energy[i] && initialExperience > experience[i]) {

                    while (initialEnergy <= energy[i]) {
                        k++;
                        initialEnergy ++;
                    }
                    initialEnergy -= energy[i];
                    initialExperience += experience[i];
                }else if(initialEnergy <= energy[i] && initialExperience <= experience[i]) {
                    while (initialEnergy <= energy[i]) {
                        k++;
                        initialEnergy ++;
                    }

                    while (initialExperience <= experience[i]) {
                        m++;
                        initialExperience ++;
                    }
                    initialEnergy -= energy[i];
                    initialExperience += experience[i];
                }
                n += (k + m);
            }
            return n;
        }
    }
}